<!DOCTYPE html>
<html lang = "en">
<head>
    <meta charset = "UTF-8">
    <title>Title</title>

    <!--=====================================================================-->
    <script>
        //

        window.onload = function () {
            let aA = document.getElementsByTagName('a');
            let oUl = document.getElementById('ul1');

            for (let i = 0; i < aA.length; i++) {
                aA[i].onclick = function () {
                    //与添加和插入一样,需要从父节点开始操作
                    console.log('this :',this); //当前环境 也就是aA[i]
                    oUl.removeChild(this.parentNode);

                    //注意,不可以用ali[i]来获取li的节点,因为删除后节点真的少了,而length也会发生变化,导致无法删除某个节点的现象


                }
            }
        }



    </script>
</head>

<body>

<div>
    <ul id="ul1">
        <li>111 <a href = "javascript:void(0);">del</a></li>
        <li>222 <a href = "javascript:void(0);">del</a></li>
        <li>333 <a href = "javascript:void(0);">del</a></li>
    </ul>

</div>

</body>
</html>